// 用户列表项
const componentBehavior = require('../../../behaviors/component');
import { COMPONENT_OPTIONS } from '../../../constants/common';
import { getPicFullPath } from '../../../common/utils';

Component({
    behaviors: [componentBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        userId: {
            type: Number,
            optionalTypes: [String],
        },
        avatar: {
            type: String,
            value: '',
        },
        name: {
            type: String,
            value: '',
        },
        nickName: {
            type: String,
            value: '',
        },
        desc: {
            type: String,
            value: '',
        },
        leftLabel: {
            type: String,
            value: '',
        },
        leftValue: {
            type: String,
            value: '',
        },
        centerLabel: {
            type: String,
            value: '',
        },
        centerValue: {
            type: String,
            value: '',
        },
        rightLabel: {
            type: String,
            value: '',
        },
        rightValue: {
            type: String,
            value: '',
        },
        hasOtherInfo: {
            type: Boolean,
            value: true,
        },
        hasMore: {
            type: Boolean,
            value: true,
        },
    },
    observers: {
        'avatar': function (pic) {
            this.setData({ avatarUrl: getPicFullPath(pic) });
        },
    },
    data: {
        avatarUrl: '',
    },
    methods: {
        clickAction: function () {
            this.triggerEvent('click', this.data.userId);
        },
        moreAction: function () {
            this.triggerEvent('more', this.data.userId);
        },
    }
})
